package com.wm.platform.user.service;

import com.wm.base.BaseService;
import com.wm.platform.user.model.User;
import com.wm.platform.user.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

/**
 * Created by sevelli on 2017/5/16.
 */
@Service
public class UserService extends BaseService{
    @Autowired
    private UserRepository userRepository;

    public User getUserById(Long id){
        return userRepository.findOne(id);
    }

    public Page<User> getPage(User user, PageRequest request) {
        Example<User> userExample = Example.of(user);
        return userRepository.findAll(userExample,request);
    }
}
